package com.hifar;

import com.hifar.abi.dc.dt.ds.DcDataSourceUtils;
import com.hifar.fw.boot.HifarLauncher;
import com.hifar.sys.AesExtractUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author dell
 */
@EnableScheduling
@EnableAspectJAutoProxy
@EnableAsync
@Slf4j
@SpringBootApplication(scanBasePackages = {"com.hifar"})
public class TemplateProjectApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(TemplateProjectApplication.class, args);
        HifarLauncher.loadBase();
        HifarLauncher.loadDaoModule();
        DcDataSourceUtils.loadDatasource();
        HifarLauncher.loadHttpModule();
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        log.info("\n----------------------------------------------------------\n\t" +
                "机器码 : \t "+ AesExtractUtil.getThisDigest()+"\n" +
                "Application Hifar-platForm is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + "/\n\t" +
                "online: \t\thttp://"+ ip +":" + port + "/\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + "/swagger-ui/index.html\n" +
                "----------------------------------------------------------");
    }

}
